//
//  YWLocationCell.m
//  maintain
//
//  Created by 烟雨云渊 on 16/8/22.
//  Copyright © 2016年 ewin. All rights reserved.
//

#import "YWLocationCell.h"
#import "Masonry.h"
#import "UIColor+CustomColors.h"
#import "YWCommonTool.h"
#import "YWMacro.h"

@interface YWLocationCell()
@property (nonatomic, strong) UIImageView * locationImageView;
@property (nonatomic, strong) UILabel * locationLabel;
@end

@implementation YWLocationCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString*)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self setUpSubviews];
    }
    
    return self;
}

- (void)setLocationText:(NSString *)locationText{
    _locationText = locationText;
    self.locationLabel.text = locationText.length?locationText:@"无";
}

- (UIImageView *)locationImageView{
    if (!_locationImageView) {
        UIImageView * locotionImageView = [[UIImageView alloc] init];
        locotionImageView.image = [UIImage imageNamed:@"common_location"];
        [self.contentView addSubview:locotionImageView];
        _locationImageView = locotionImageView;
    }
    return _locationImageView;
}

- (UILabel *)locationLabel{
    if (!_locationLabel) {
        UILabel * locationLabel = [[UILabel alloc] init];
        locationLabel.font = kContentFont;
        locationLabel.numberOfLines = 0;
        [self.contentView addSubview:locationLabel];
        _locationLabel = locationLabel;
    }
    return _locationLabel;
}

- (void)setUpSubviews{
    [self.locationLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.contentView.mas_top).offset(10);
        make.left.mas_equalTo(self.contentView.mas_left).offset(10+17+10);
        make.right.mas_equalTo(self.contentView.mas_right).offset(-10);
        make.bottom.mas_equalTo(self.contentView.mas_bottom).offset(-10);
    }];
    [self.locationImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.contentView).offset(10);
        make.centerY.mas_equalTo(self.locationLabel.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(17, 17));
    }];
}

@end



